# Merb::Router is the request routing mapper for the merb framework.
#
# You can route a specific URL to a controller / action pair:
#
#   r.match("/contact").
#     to(:controller => "info", :action => "contact")
#
# You can define placeholder parts of the url with the :symbol notation. These
# placeholders will be available in the params hash of your controllers. For example:
#
#   r.match("/books/:book_id/:action").
#     to(:controller => "books")
#   
# Or, use placeholders in the "to" results for more complicated routing, e.g.:
#
#   r.match("/admin/:module/:controller/:action/:id").
#     to(:controller => ":module/:controller")
#
# You can also use regular expressions, deferred routes, and many other options.
# See merb/specs/merb/router.rb for a fairly complete usage sample.

Merb.logger.info("Compiling routes...")
Merb::Router.prepare do |r|
  r.resources :petrinets do |p|
   p.match("/case/:case_id", :method => "get").to(:controller => 'petrinets', :action =>'show')
   #p.match("/timestamps", :method => "get").to(:controller => 'petrinets', :action =>'timestamps')
  end
  
  r.match("/overview", :method => "get").to(:controller => 'cases', :action =>'overview')    
  r.resources :cases
  r.resources :execution_logs
  r.resources :execution_context
  r.resources :transition_modes do |m|
    m.match("/:id/undo", :method => "post").to(:controller => 'transition_modes', :action => 'undo')
    m.match("/:id/redo", :method => "post").to(:controller => 'transition_modes', :action => 'redo')
  end
  r.resources :places do |p|
	  p.resources :tokens
  end
  
  r.resources :transitions do |t|
    # /transition/:id/tokens && /transition/:id/tokens/ && /transition/:id/tokens/1/2
    t.match(/^\/tokens(?:\/([0-9\/;]*))?/, :method => "get").to(:controller => 'transitions', :action =>'show_token_comb', :tokens => "[2]")
    t.match(/^\/tokens(?:\/([0-9\/;]*))?/, :method => "post").to(:controller => 'transitions', :action =>'fire', :tokens => "[2]")
    t.match("", :method => "post").to(:controller => 'transitions', :action =>'fire')
    t.match("/case/:case_id", :method => "get").to(:controller => 'transitions', :action =>'show_token_comb')
    t.match("/case/:case_id", :method => "post").to(:controller => 'transitions', :action =>'fire')
  end
  
  
  #document upload
  r.match("/documents", :method => "post").to(:controller => 'documents', :action => 'create')
  r.match("/benchmark", :method => "get").to(:controller => 'engine', :action => 'benchmark')
  
  # This is the default route for /:controller/:action/:id
  r.default_routes
  
  r.match(/\/?/).to(:controller => 'engine', :action =>'index')
end